package com.five.welcome.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.five.welcome.entity.Admissioninfo;
import com.five.welcome.result.Result;
import com.five.welcome.service.AdmissioninfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * @author Ywt
 */
@Tag(name = "录取信息接口")
@RestController
@CrossOrigin
@RequestMapping("/admissioninfo")
public class AdmissioninfoController {

    @Autowired
    private AdmissioninfoService admissioninfoService;

    //查询录取信息
    @Operation(summary = "查询录取信息")
    @GetMapping("/getAdmissionInfoBySNumber")
    public Result getAdmissionInfoBySNumber(String sNumber) {
        Admissioninfo admissionInfoBySNumber =
                admissioninfoService.getAdmissionInfoBySNumber(sNumber);
        if (admissionInfoBySNumber != null) {
            return Result.ok(admissionInfoBySNumber);
        }
        return Result.error("暂未查到您的录取信息");
    }

    //管理员查询所有录取信息
    @Operation(summary = "管理员查询所有录取信息")
    @GetMapping("/getAll")
    public Result getAllOfPage(@RequestParam(defaultValue = "1") Integer pageNumber,
                               @RequestParam(defaultValue = "6") Integer pageSize,
                               String sNumber, String profession, String admissionStatus) {
        Page<Admissioninfo> admissioninfos = admissioninfoService.
                getAllOfPage(pageNumber, pageSize, sNumber, profession, admissionStatus);
        return Result.ok(admissioninfos);
    }

}

